package cn.csg.ams.collect2.poptopics.infrastructure.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;

public class HuaWeiAuthentication {

    private static final Logger logger = LoggerFactory.getLogger(HuaWeiAuthentication.class);

    public static void doAuthentication(String principal, String keytab, String krb5) throws IOException {
        // windows路径下分隔符替换
        keytab = keytab.replace("\\", "\\\\");
        krb5 = krb5.replace("\\", "\\\\");

        LoginUtil.setKrb5Config(krb5);
        // "zookeeper/hadoop.cypc.bd"
//        LoginUtil.setZookeeperServerPrincipal("zookeeper/hadoop.cypc.bd@CYPC.BD");
//        "zookeeper/hadoop.tg.bd@TG.BD"
        // ProUtils.getStrValue(Configs.ZK_SERVICE_PRINCIPAL)
        LoginUtil.setZookeeperServerPrincipal("");
        LoginUtil.setJaasFile(principal, keytab);
        logger.info("认证通过了！！！");
    }

}
